package com.shxc.smarttrade.old.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.shxc.smarttrade.R;
import com.shxc.smarttrade.old.bean.HomePagerDatas;

import java.util.List;


/**
 * Created by jcdev1 on 2017/5/9.
 */

public class FootOneAdapter extends BaseAdapter {
    private Context mContext;
    private ClickListener listener;
    private List<HomePagerDatas.DataBean.MastersBean> mastersBeen;

    public FootOneAdapter(Context mContext) {
        this.mContext = mContext;
    }

    public void setDatas(List<HomePagerDatas.DataBean.MastersBean> mastersBeen) {
        this.mastersBeen = mastersBeen;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return mastersBeen == null ? 0 : mastersBeen.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        View v = View.inflate(mContext, R.layout.adapter_foot_one, null);

        v.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.itemCLickListenrer(i);
            }
        });

        ImageView ivHead = (ImageView) v.findViewById(R.id.iv_head);
        TextView tvName = (TextView) v.findViewById(R.id.tv_name);
        TextView tvTotalProfit = (TextView) v.findViewById(R.id.tv_totalprofit);
        TextView tvHistorySum = (TextView) v.findViewById(R.id.tv_historysum);
        HomePagerDatas.DataBean.MastersBean mb = mastersBeen.get(i);
        Log.e("URL", mb.getHeadUrl());
//        Picasso.with(mContext).load("http://demo.tigerwit.com/avatar/9632_150.jpg").into(ivHead);
        tvName.setText(mb.getUsername());
        tvTotalProfit.setText(mb.getTotalProfit() + "");
        tvHistorySum.setText(mb.getHistorySum() + "");

        return v;
    }

    public void setOnMyItemCLickListener(ClickListener listener) {
        this.listener = listener;
    }

    public interface ClickListener {
        void itemCLickListenrer(int position);
    }
}
